﻿using IntelligentAgriculture.Contracts.Dto.Input;
using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.LambweaninginfoCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.LambweaninginfoCommandHandler
{
	/// <summary>
	/// 获取羔羊断奶信息
	/// </summary>
	/// <returns></returns>
	public class GetLambweaninginfoCommandHandler : IRequestHandler<GetLambweaninginfoCommand, Results<PageOutput<LambweaninginfoOutPut>>>
	{
		/// <summary>
		/// 接口
		/// </summary>
		private readonly ILambweaninginfoService _lambweaninginfoService;
		/// <summary>
		/// 构造函数
		/// </summary>
		/// <param name="lambweaninginfoService"></param>

		public GetLambweaninginfoCommandHandler(ILambweaninginfoService lambweaninginfoService)
		{
			_lambweaninginfoService = lambweaninginfoService;
		}
		/// <summary>
		/// 获取羔羊断奶信息
		/// </summary>
		/// <returns></returns>
		public async Task<Results<PageOutput<LambweaninginfoOutPut>>> Handle(GetLambweaninginfoCommand request, CancellationToken cancellationToken)
		{
			var input = new LambWeaningInfoInPut()
			{
				EarTag = request.EarTag,
				EndDate = request.EndDate,
				EndWeaningWeight = request.EndWeaningWeight,
				EndMonthold = request.EndMonthold,
				MammalianNumber = request.MammalianNumber,
				PageIndex = request.PageIndex,
				PageSize = request.PageSize,
				StartMonthold = request.StartMonthold,
				StartWeaningWeight = request.StartWeaningWeight,
				StrartDate = request.StrartDate
			};
			var result = await _lambweaninginfoService.GetLambweaninginfos(input);
			return Results<PageOutput<LambweaninginfoOutPut>>.DataResult(result);
		}
	}
}
